import urllib.parse
import urllib.request

url = 'https://fanyi.baidu.com/sug'

headers = {
    'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36'
}

data = {
    'kw': 'order'
}

# post 请求的参数必须urlEncode
data = urllib.parse.urlencode(data).encode('utf-8')

# 创建请求对象
request = urllib.request.Request(url=url, data=data, headers=headers)

# 发送请求
response = urllib.request.urlopen(request)

# 获取响应数据
content = response.read().decode('utf-8')

print(content)
# 转为json对象
import json

obj = json.loads(content)
print(obj)
